<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
 <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="">
  <div class="layui-form-item">
    <label class="layui-form-label">单行输入框</label>
    <div class="layui-input-block">
      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
  </div>

<div class="layui-form-item">
    <label class="layui-form-label">文章内容</label>
    <div class="layui-input-block">
      <!-- 富文本框 -->
		<textarea id="demo" style="display: none;"></textarea>
    </div>
</div>

 <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">分类</label>
      <div class="layui-input-inline">
<select name="category" lay-verify="required" lay-search="">

          <option value="">请选择你的分类</option>
          <option value="1">layer</option>
          <option value="2">form</option>
          <option value="3">layim</option>
          <option value="4">element</option>
          <option value="5">laytpl</option>
          <option value="6">upload</option>
          <option value="7">laydate</option>

        </select>
      </div>
    </div>
  </div>


 <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script src="../layui/layui.js"></script>
<script>
//一般直接写在一个js文件中
layui.use(['layer', 'form','layedit'], function(){
  var layer = layui.layer
  ,form = layui.form;
  //富文本编辑器
  var layedit = layui.layedit;
  //index表示监听的第几个编辑器
  var index=layedit.build('demo'); //建立编辑器
  
  
  //用layui内部的jquery
  var $=layui.$;
  
//监听提交
  form.on('submit(demo1)', function(data){
	//手动取富文本编辑器的方法
	  //layedit.getContent(index)获得编辑器的内容 
      //参数 index： 即执行layedit.build返回的值
	 // console.log(layedit.getContent(index));
	
	//在控制台打印出富文本编辑器的内容和其他内容
	//console.log(data.field);
	
	//将富文本内容合并到其他内容
	data.field.content=layedit.getContent(index);
	console.log(data.field);
	//localhost/blog/post_add
	$.get("../post_add", data.field, function(data){
		console.log(data);
	  
    });
    return false;
  });
  
});


</script> 

</body>
</html>